#pragma once
#include "Controller.h"

using namespace std;

Controller::Controller(Aquarium* _aquarium):
	feedButton(string("feed")),
	emptyButton(string("empty")),
	debugButton(string("debug")),
	pauseButton(string("pause")),
	addFishButton(string("add")),
	removeFishButton(string("remove")){
	this->aquarium = _aquarium;
	this->setObserever(_aquarium);
}

Controller::~Controller(){
	this->removeObeserver(aquarium);
	this->aquarium = 0;
}

Controller::Controller(const Controller& controller):
	feedButton(string("feed")),
	emptyButton(string("empty")),
	debugButton(string("debug")),
	pauseButton(string("pause")),
	addFishButton(string("add")),
	removeFishButton(string("remove")){
	this->aquarium = controller.aquarium;
}
const Controller& Controller::operator=(const Controller& controller){

	if (this != &controller){
		this->aquarium = controller.aquarium;
	}

	return *this;
}


// controller methods
void Controller::setObserever(Observer* obs){
	feedButton.Attach(obs);
	emptyButton.Attach(obs);
	pauseButton.Attach(obs);
	debugButton.Attach(obs);
}

void Controller::removeObeserver(Observer* obs){
	feedButton.Detach(obs);
	emptyButton.Detach(obs);
	pauseButton.Detach(obs);
	debugButton.Detach(obs);
}

void Controller::feed(){
	feedButton.click();
}

void Controller::empty(){
	emptyButton.click();
}

void Controller::pause(){
	pauseButton.click();
}

void Controller::debug() {
	debugButton.click();
}